package com.swlz.servlet.user;

import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;

import com.swlz.R;
import com.swlz.entity.User;
import com.swlz.service.RoleService;
import com.swlz.service.UserService;
import com.swlz.service.impl.RoleServiceImpl;
import com.swlz.service.impl.UserServiceImpl;
import com.swlz.servlet.HttpServletSupport;
/**
 * 前台个人中心管理
 * @author swlz
 *
 */
@WebServlet("/user/user.let")
public class UserServlet extends HttpServletSupport{
	private UserService userService = new UserServiceImpl();
	private RoleService roleService = new RoleServiceImpl();
	
	public String excute(User user,HttpServletRequest request)throws Exception {
		request.setAttribute("user", userService.get(user.getUserId()));
		request.setAttribute("role", roleService.get(user.getRoleId()));
		log.debug("初始化角色信息完成");
		return "forward:/user/person-information.jsp";
	}
	
	
	public R<?> update(User user)throws Exception {
//		log.debug("aaaaaaaa");
		log.debug(user.toString());
		userService.update(user);
		log.debug("成功");
		return R.ok();
	}

}
